﻿using System;

namespace Simple3DRedactor.Domain
{
    [Serializable]
    public class Box : Geometry
    {
        public Box()
        {
            Name = "Box";

            Width = Height = Depth = 1.0f;
        }

        private float _width;
        public float Width
        {
            get { return _width; }
            set
            {
                if (Math.Abs(_width - value) > float.Epsilon)
                {
                    _width = value;
                    OnChange();
                }
            }
        }

        private float _height;
        public float Height
        {
            get { return _height; }
            set
            {
                if (Math.Abs(_height - value) > float.Epsilon)
                {
                    _height = value;
                    OnChange();
                }
            }
        }

        private float _depth;
        public float Depth
        {
            get { return _depth; }
            set 
            {
                if (Math.Abs(_depth - value) > float.Epsilon)
                {
                    _depth = value;
                    OnChange();
                } 
            }
        }

        public override TV CreateView<TV>(IObjectViewFactory<TV> factory)
        {
            return factory.Create(this);
        }
    }
}
